package cn.volunteer.points.system.config.handle;

import cn.volunteer.points.system.handle.AuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description: 拦截器配置
 * @author:
 * @create: 创建时间：2021-04-18
 **/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {


    /**
     * 拦截所有请求url
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/**");
    }

    /**
     * 注入自定义的拦截器
     * @return
     */
    @Bean
    public AuthenticationInterceptor authenticationInterceptor(){
       return  new AuthenticationInterceptor();
    }
}
